using System;
using System.Collections.Generic;
using System.Text;
using MyCityCab.Core.View;
using WebFramework;
using System.Web.Security;
using System.Web;

namespace MyCityCab.Core
{
    public partial class UserController
    {
        ILoginView _loginView;

        public UserController(ILoginView loginView)
        {
            _loginView = loginView;
        }

        public bool PerformLogin()
        {
            ReturnValue<User> result = User.Login(_loginView.Username, _loginView.Password);
            if (result.IsFalse)
                return false;
            FormsAuthentication.SetAuthCookie(_loginView.Username, _loginView.RememberMe);
            if(!String.IsNullOrEmpty(_loginView.ReturnUrl))
                HttpContext.Current.Response.Redirect(_loginView.ReturnUrl);
            return true;
        }
    }
}
